home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
proxy14.arj
/
EMAIL.PRX
< prev
next >
Wrap
Text File
|
1991-10-23
|
2KB
|
61 lines
// state components
// up = map(string,string)
// uq = map(string,queue)
// so = set(string)
class queue(procd,remdr) {
read(;x) {
if(len remdr==0) return "empty queue";
x=hd remdr;
remdr=tl remdr;
procd=procd conc [x];
return x;}
write(msg) {remdr=remdr conc [msg];}
reset() {remdr=procd conc remdr;
procd=[];}
delete() {if(len procd==0) return "empty queue";
procd=butlast procd;} };
up={"super" -> "super"}; // initialize super user with pw "super"
uq={"super" -> new queue([],[])}; // initialize mail-queue for super user
// can send mail to him
struct mail {sender,text;};
add(u,n,pw) {if (u != "super") return {"not authorized",u};
uq[n]=new queue([],[]); // initializes mail-queue
up[n]=pw; // initializes password
return "ok";};
drop(u,n) {if (u != "super") return {"not authorized",u};
if (n notin dom up) return {"unknown user",n};
up=up ds {n}; // remove user and password
uq=uq ds {n}; // remove user and mail-queue
if(n in so) so=so diff {n}; // if user signed on, sign
return "ok";}; // him off
signon(u,pw) {if (u notin dom up) return {"unknown user", u};
if (up[u,""] != pw) return "incorrect password";
so=so U {u}; // sign him on
return "ok";};
signoff(u) {if (u notin so) return {"not signed on",u};
so=so diff {u}; // sign him off
return "ok";};
send(u,t,r;x) { if (u notin so) return {"not signed on",u};
if (r notin dom up) return {"unknown user",r};
x=uq[r];
x.write(new mail(u,t)); // create mail and send
return "ok";};
read(u;x) {if (u notin so) return {"not signed on",u};
x=uq[u];
return x.read;}; // read mail
reset(u;x) {if (u notin so) return {"not signed on",u};
x=uq[u];
x.reset; // reset mail-queue
return "ok";};
delete(u;x) {if (u notin so) return {"not signed on",u};
x=uq[u];
x.delete; // delete mail
return "ok";};
so= {};
end